
const express = require('express');
const fs = require('fs');
const cors = require('cors');
const app = express();


// app.use(cors({
//     credentials: true,
//     optionsSuccessStatus: 200,
//     origin: 'http://127.0.0.1:5500'
// }));

app.use(express.static('./public'));

app.get('/user',(request,response) => {
    const user = {
                    name:'吴翔',age:26,
                    sex:'男',tel:'1145141919',
                    email:'litangdingzhen@qq.com',
                    location:'四川省甘孜藏族自治州',
                    locationlink:'https://map.baidu.com/search/%E7%94%98%E5%AD%9C%E8%97%8F%E6%97%8F%E8%87%AA%E6%B2%BB%E5%B7%9E/@11351210,3489061.25,13.67z?querytype=s&wd=%E7%94%98%E5%AD%9C%E8%97%8F%E6%97%8F%E8%87%AA%E6%B2%BB%E5%B7%9E&c=73&provider=pc-aladin&pn=0&device_ratio=2&da_src=shareurl',
                    
                };
    fs.readFile('./dz.webp',(err,data) => {
        if(err){
            response.sendStatus(400);
            console.log("err");
        }else{
            user.avatar = data.toString('base64');
            response.send(user);
        }
    })
})

app.listen(3000,function(){
    console.log('server started at http://127.0.0.1:3000');
})